<?php

class App_General_Url
{
    /**
     * 
     */
    public static function friendly( $value )
    {
        $strComCaracter = array( "\"", "\'", '\'', 'r$', '$', '&', '%', '#', '@', ',', '.', '|', '_', '-', '+', '/', '*', ':', ';', '!', '?', '(', ')', '{', '}', '[', ']' );
        $strSemCaracter = array( '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' );
        
        $strComComum = array( ' a ', ' e ', ' o ', ' da ', ' de ', ' do ', ' em ' );
        $strSemComum = array( ' ', ' ', ' ', ' ', ' ', ' ', ' ' );
        
        $value = htmlentities( strtolower( $value ), ENT_NOQUOTES, 'UTF-8' );
        $value = preg_replace( '/&(.)(acute|cedil|circ|ring|tilde|uml);/', '$1', $value );
        $value = str_replace( $strComCaracter, $strSemCaracter, $value );
        $value = str_replace( $strComComum, $strSemComum, $value );
        $value = preg_replace( '/( +)/', '-', trim( $value ) );
        
        return $value;
    } 
}
